/*
 * @lc app=leetcode.cn id=1614 lang=cpp
 *
 * [1614] 括号的最大嵌套深度
 */

// @lc code=start
class Solution
{
public:
  int maxDepth(string str)
  {
    stack<char> s;
    size_t md = 0;
    for (char c : str) {
      if (c == '(')
        s.push(c);
      else if (c == ')') {
        md = std::max(md, s.size());
        s.pop();
      }
    }
    return md;
  }
};
// @lc code=end
